home *** CD-ROM | disk | FTP | other *** search
- package java.net;
-
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.OutputStream;
-
- public final class Socket {
- SocketImpl impl;
- private static SocketImplFactory factory;
-
- Socket() {
- this.impl = (SocketImpl)(factory != null ? factory.createSocketImpl() : new PlainSocketImpl());
- }
-
- public Socket(String var1, int var2) throws UnknownHostException, IOException {
- this(var1, var2, true);
- }
-
- public Socket(String var1, int var2, boolean var3) throws IOException {
- this();
- String var4 = new String(var1);
- SecurityManager var5 = System.getSecurityManager();
- if (var5 != null) {
- var4 = InetAddress.getByName(var4).getHostAddress();
- var5.checkConnect(var4, var2);
- }
-
- try {
- this.impl.create(var3);
- this.impl.connect(var4, var2);
- } catch (IOException var7) {
- this.impl.close();
- throw var7;
- }
- }
-
- public Socket(InetAddress var1, int var2) throws IOException {
- this(var1, var2, true);
- }
-
- public Socket(InetAddress var1, int var2, boolean var3) throws IOException {
- this();
- SecurityManager var4 = System.getSecurityManager();
- if (var4 != null) {
- var4.checkConnect(var1.getHostAddress(), var2);
- }
-
- try {
- this.impl.create(var3);
- this.impl.connect(var1, var2);
- } catch (SocketException var6) {
- this.impl.close();
- throw var6;
- }
- }
-
- public InetAddress getInetAddress() {
- return this.impl.getInetAddress();
- }
-
- public int getPort() {
- return this.impl.getPort();
- }
-
- public int getLocalPort() {
- return this.impl.getLocalPort();
- }
-
- public InputStream getInputStream() throws IOException {
- return this.impl.getInputStream();
- }
-
- public OutputStream getOutputStream() throws IOException {
- return this.impl.getOutputStream();
- }
-
- public synchronized void close() throws IOException {
- this.impl.close();
- }
-
- public String toString() {
- return "Socket[addr=" + this.impl.getInetAddress() + ",port=" + this.impl.getPort() + ",localport=" + this.impl.getLocalPort() + "]";
- }
-
- public static synchronized void setSocketImplFactory(SocketImplFactory var0) throws IOException {
- if (factory != null) {
- throw new SocketException("factory already defined");
- } else {
- SecurityManager var1 = System.getSecurityManager();
- if (var1 != null) {
- var1.checkSetFactory();
- }
-
- factory = var0;
- }
- }
- }
-